package club.ruanx.auth.vcode.config;

import club.ruanx.auth.vcode.factory.ValidateCodeGenerator;
import club.ruanx.auth.vcode.image.ImageCodeGenerator;
import club.ruanx.auth.vcode.repository.RedisValidateCodeRepository;
import club.ruanx.auth.vcode.repository.ValidateCodeRepository;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author 阮胜
 * @date 2018/9/30 14:03
 */
@Configuration
public class ValidateCodeBeanConfig {
    @Bean("imageCodeGenerator")
    @ConditionalOnMissingBean(ValidateCodeGenerator.class)
    public ValidateCodeGenerator validateCodeGenerator() {
        return new ImageCodeGenerator();
    }

    @Bean
    @ConditionalOnMissingBean(ValidateCodeRepository.class)
    public ValidateCodeRepository validateCodeRepository() {
        return new RedisValidateCodeRepository();
    }

}
